-
Notifications
You must be signed in to change notification settings - Fork 0
Refactored project structure #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Should we aim for one public function per file or per some grouping criteria? For example, the This is just a general rule or guideline and we can break them as needed. Just want to bring the question up front. This is related to O/C at the file level which affects mergability. |
The main issue is that you should only have one package name per folder. If you put everything in the root internal folder, they would all be package internal, which would mess up all the namespaces. |
Sure, in that case, may be |
Another comment is about |
CollabStyle is a good name. I can also change the filename to filter/on_collab_style.go |
How about changing the filter directory and package name to matcher? matcher is a more general name for the purpose of the package as opposed to filter which is more of an implementation strategy. |
I wouldn't worry too much about it because we are still at the very beginning, things are pretty much in flux. In fact, these logic can be changed drastically and we may ended up with a query/graphQL like code that there is one function that handles all the detail filtering and perform some additional match based on the result. So, until then, I would say what we currently have is ok. My two cents. 🌷 |
I made the suggested changes. Don't worry about making suggestions, I'm using GoLand so refactoring is not a big problem. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I fully understand what 1 package per folder means, but it's not a big deal and I'll take your word on it for now.
But we do need to update the test names.
"testing" | ||
) | ||
|
||
func TestFilterOnCoStyleReturnsEmpty(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We changed coStyle to colabStyle, but didn't update the test names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I forgot to update them. I'll do that.
internal/criteria/criteria.go
Outdated
@@ -0,0 +1,11 @@ | |||
package criteria | |||
|
|||
// CollabStyle .. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more out of annoyance. The linter in VScode keeps complaining when you don't put a comment. I don't know how to turn off the linter rule. I'm ok to delete them. I mostly use goland, so it's not much of an issue for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There got to be a way. I would say it is ok to keep them in this PR,
and the next PR add .vscode/settings.json
to turn it off and remove these comments.
And in the travis turn on any linter check. I know that go compiler do some linting itself, but don't know about which linter the vscode extension based on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have looked, but wasn't able to find a way. I ended up just creating a snippet that added them automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these comments supposed to be doc generating comments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I see these are required. We should probably add godoc to the travis yaml.
https://golang.org/doc/effective_go.html#commentary
Since these comments are actually treated like code, they probably don't break the clean code "no comment" rules. And we should probably fill them in. Thoughts?
I'll raise this on the channel.
internal/filter/on_collab_style.go
Outdated
|
||
// OnCollabStyle .. | ||
func OnCollabStyle(users []user.User, coStyle criteria.CollabStyle) (matchedUsers []user.User) { | ||
matchedUsers = []user.User{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A note for later.
If we use this style on all the match filters then we will end up looping through the entire user database multiple times.
We should make note to eventually only loop through the user DB once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also had a thought about this type of filter method. Because it's filtering out all the users that don't match with this specific criteria, if you were to use a chain of filters (in a functional way), the 'filtered out' users would not be present to be matched to other criterias. So, perhaps just returning the matching users might not be enough.
Instead we might want to consider using a new data structure that contains the user and a list of matches that have occurred. The function would be less of a filter and more of a matcher.
Based on this: https://github.com/golang-standards/project-layout/blob/master/internal/README.md Should we do |
Stupid phone, I did not mean to close the PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the insights.
Umm, I just found this issue. |
Created basic project structure and moved production code into separate packages.